import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import Login from './views/login.vue'
Vue.use(Router)

export default new Router({
  // 登录的路由规则
  routes: [{
    path: '/login',
    name: 'login',
    component: Login
  },
  // 首页的路由规则
  {
    path: '/',
    name: 'home',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
    component: Home,
    // 当访问的是home是，让路由重定位到欢迎页面
    redirect: {
      name: 'welcome'
    },
    children: [{
      path: '/users',
      name: 'users',
      component: () => import(/* webpackChunkName: "about" */ './views/Users.vue')
    }, {
      path: '/welcome',
      name: 'welcome',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/welcome.vue')
    }]
  }

  ]
})
